#include "chatlistwidget.h"
#include "ui_chatlistwidget.h"
#include "QHBoxLayout"
#include "QVBoxLayout"
#include "QPainter"
#include "someItem/groupchatitem.h"
ChatListWidget::ChatListWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ChatListWidget)
{
    ui->setupUi(this);
    initUI();
    initStyle();
    SetChatItem();
    SetChatItem();
    SetChatItem();
}

ChatListWidget::~ChatListWidget()
{
    delete ui;
}

void ChatListWidget::SetChatItem()
{
    GroupChatItem* item1 = new GroupChatItem();
    QListWidgetItem* listItem1 = new QListWidgetItem(ui->m_listWidget);
    listItem1->setSizeHint(item1->size());
    ui->m_listWidget->setItemWidget(listItem1, item1);
}
void ChatListWidget::initUI() {
    ui->m_listWidget->setStyleSheet("QListWidget { border: none; }");
    ui->m_listWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);

}

void ChatListWidget::initStyle() {
    // 全局样式表
    setStyleSheet(R"(
        QWidget {
            background-color: #f5f5f5;
        }
        QListWidget {
            background-color: #fff;
        }
        GroupChatItem:hover {
            background-color: #f0f0f0;
        }
        QLabel {
            font-family: "Microsoft YaHei";
        }
    )");
}


